﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ObjectFeatures;

namespace WpfAlarmTimer
{
    /// <summary>
    /// Interaction logic for TimerEditDialog.xaml
    /// </summary>
    public partial class TimerEditDialog : Window
    {
        private Timer _timer;

        public Timer Timer { get { return _timer; } }

        private TimerEditDialog(Timer timer, bool showDelete)
        {
            this._timer = timer;
            this.DataContext = this._timer;
            this._result = TimerEditDialogResult.None;
            InitializeComponent();
            if (!showDelete) this.deleteButton.Visibility = Visibility.Collapsed;
        }

        public static TimerEditDialogResult Show(Timer timer, bool showDelete){
            TimerEditDialog dialog = new TimerEditDialog(timer, showDelete);
            bool? result = dialog.ShowDialog();
            return dialog._result;
        }
        public static TimerEditDialogResult Show(Timer timer)
        {
            return Show(timer, false);
        }

        private void saveButton_Click(object sender, RoutedEventArgs e)
        {
            this._timer.StartTime = DateTime.Now;
            this._result = TimerEditDialogResult.Save;
            this.Close();
        }

        public TimerEditDialogResult _result { get; set; }

        private void deleteButton_Click(object sender, RoutedEventArgs e)
        {
            this._result = TimerEditDialogResult.Delete;
            this.Close();
        }
    }
    public enum TimerEditDialogResult {
        Save, Delete, None
    } 
}
